package com.piggy.logi.sys.api.controller;

import com.piggy.common.core.domain.R;
import com.piggy.common.core.web.controller.BaseController;
import com.piggy.logi.sys.api.bo.*;
import com.piggy.logi.sys.api.service.ZhongYouApiService;
import com.piggy.logi.sys.api.vo.TransComVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * 众油平台可调用API controller
 *
 * @author fengxy
 * @date 2024/01/15 15:35
 **/
@Api(value = "众油平台可调用API", tags = {"众油平台可调用API"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/logi/zhongYou/api")
public class ZhongYouApiController extends BaseController {

    private final ZhongYouApiService zhongYouApiService;

    /**
     * 获取物流平台（启用）服务商
     *
     * @author fengxy
     * @date 2024/01/15 14:59
     **/
    @ApiOperation("获取物流平台（启用）服务商")
    @PostMapping("/getTransComList")
    public R<List<TransComVo>> getTransComList(@Validated @RequestBody TransComQueryBo bo) {
        return R.ok(zhongYouApiService.getTransComList(bo));
    }

    /**
     * 订单价格预估
     *
     * @author fengxy
     * @date 2024/01/15 14:59
     **/
    @ApiOperation("订单价格预估")
    @PostMapping("/tryService")
    public R<BigDecimal> tryService(@Validated @RequestBody TryServiceBo bo) {
        return R.ok(zhongYouApiService.tryService(bo));
    }

    /**
     * 运油下单
     *
     * @author fengxy
     * @date 2024/01/15 14:59
     **/
    @ApiOperation("运油下单")
    @PostMapping("/order")
    public R<Object> addOrder(@Validated @RequestBody AddOrderBo bo) {
        zhongYouApiService.addOrder(bo);
        return R.ok();
    }

    /**
     * 取消订单
     *
     * @author fengxy
     * @date 2024/01/15 14:59
     **/
    @ApiOperation("取消订单")
    @PostMapping("/cancelOrder")
    public R<Object> cancelOrder(@Validated @RequestBody CancelOrderBo bo) {
        zhongYouApiService.cancelOrder(bo);
        return R.ok();
    }

    /**
     * 确认发车
     *
     * @author fengxy
     * @date 2024/01/15 14:59
     **/
    @ApiOperation("确认发车")
    @PostMapping("/confirmSchedule")
    public R<Object> confirmSchedule(@Validated @RequestBody ConfirmScheduleBo bo) {
        zhongYouApiService.confirmSchedule(bo);
        return R.ok();
    }

    /**
     * 更新实际提货信息
     *
     * @author fengxy
     * @date 2024/01/15 14:59
     **/
    @ApiOperation("更新实际提货信息")
    @PostMapping("/realPickupInfo")
    public R<Object> realPickupInfo(@Validated @RequestBody RealPickupInfoBo bo) {
        zhongYouApiService.realPickupInfo(bo);
        return R.ok();
    }

    /**
     * 更新支付金额和支付时间
     *
     * @author fengxy
     * @date 2024/01/15 14:59
     **/
    @ApiOperation("更新支付金额和支付时间")
    @PostMapping("/payInfo")
    public R<Object> payInfo(@Validated @RequestBody PayInfoBo bo) {
        zhongYouApiService.payInfo(bo);
        return R.ok();
    }

    /**
     * 根据详细地址获取经纬度
     *
     * @author fengxy
     * @date 2024/01/15 14:59
     **/
    @ApiOperation("根据详细地址获取经纬度")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "address", value = "详细地址（省+市+区+详细地址，例：广东省深圳市南山区深圳大学）", required = true, dataTypeClass = String.class),
    })
    @PostMapping("/getLngAndLatByAddress")
    public R<String> getLngAndLatByAddress(@RequestParam String address) {
        return R.ok(zhongYouApiService.getLngAndLatByAddress(address));
    }
}
